package cn.wolfcode.business.controller;

import cn.wolfcode.business.domain.BusStatementItem;
import cn.wolfcode.business.domain.vo.StatementItemVO;
import cn.wolfcode.business.service.BusStatementItemService;
import cn.wolfcode.common.core.controller.BaseController;
import cn.wolfcode.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/business/item")
public class BusStatementItemController extends BaseController {
    @Autowired
    private BusStatementItemService busStatementItemService;

    @PostMapping
    public AjaxResult save(@RequestBody StatementItemVO vo) {
        return toAjax(busStatementItemService.save(vo));
    }

    @GetMapping
    public AjaxResult list(Long statementId) {
        List<BusStatementItem> list = busStatementItemService.list(statementId);
        return AjaxResult.success(list);
    }

    @PatchMapping("/{statementId}")
    public AjaxResult pay(@PathVariable Long statementId) {
        return toAjax(busStatementItemService.pay(statementId));
    }
}
